#ifndef __STORMWIDGET_CONFIGMANAGE_CTASKSTATEOBSERVER_TASKSTATEOBSERVER_H
#define __STORMWIDGET_CONFIGMANAGE_CTASKSTATEOBSERVER_TASKSTATEOBSERVER_H

#include "ITaskEvent.h"
#include <vector>
#include "AutoLock.h"



class CTaskStateObserver
{
public:
	CTaskStateObserver(void);
	virtual ~CTaskStateObserver(void);
	virtual HRESULT RegisterObserver(ITaskEvent* pEvent);
	virtual HRESULT UnRegisterObserver(ITaskEvent* pEvent);
private:
	std::vector<ITaskEvent*> m_pEventList;
	CCritSec m_csTaskState;
};

#define FOREACH_TASKSTATE_BEGIN(pEvent)				               \
{\
	CAutoLock m_AutoLock(m_csTaskState);							\
	for(std::vector<ITaskEvent>::iterator it = m_pEventList.begin();  \
	it!=m_pEventList.end();++it)	                               \
{																	 \
	pEvent = (*it);								                   \

#define FOREACH_TASKSTATE_END()									   \
}\
}
#endif //__STORMWIDGET_CONFIGMANAGE_CTASKSTATEOBSERVER_TASKSTATEOBSERVER_H